<?php

namespace App\Models;

class Roles extends BaseModel
{
    protected $table = 'roles';

    public function power()
    {
        return $this->belongsToMany(Power::class, 'role_power', 'role_id', 'power_id')->as('role_power');
    }

    public function getPowerListAttribute(){
        $powerList = $this->power->pluck('code');
        $this->makeHidden('power');
        return $powerList;
    }
}
